In general, image encoding and decoding apparatuses using a template determine a prediction block for an encoding target block by matching the template of the encoding target block with all restored reference images.
In particular, the image encoding and decoding apparatuses determine a matching target region by using only distortion between the template of the encoding target block and the matching target region and determine the prediction block of the encoding target block based on the determined matching target region.
However, when only the distortion between the template of the encoding target block and the matching target region is used, an error between the prediction block corresponding to the matching target region having minimum distortion and the encoding target block may be large.
Moreover, as template matching is performed using all the restored reference images, calculation complexities of the image encoding and decoding apparatuses increase.
Therefore, the technologies for image encoding and decoding capable of reducing the error between the prediction block and the encoding target block while reducing the calculation complexities are required.